﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace MotionFramework.Editor
{
    /// <summary>
    /// 自动绑定全局设置
    /// </summary>
    public class AutoBindGlobalSetting : ScriptableObject
    {
        [SerializeField]
        private string m_CodePath;

        [SerializeField]
        private string m_Namespace;

        public string CodePath
        {
            get
            {
                return m_CodePath;
            }

        }

        public string Namespace
        {
            get
            {
                return m_Namespace;
            }
        
        }

        [MenuItem("MotionTools/CreateAutoBindGlobalSetting", false, 111)]
        private static void CreateAutoBindGlobalSetting()
        {
            string[] paths = AssetDatabase.FindAssets("t:AutoBindGlobalSetting");
            if (paths.Length >= 1)
            {
                string path = AssetDatabase.GUIDToAssetPath(paths[0]);
                EditorUtility.DisplayDialog("警告", $"已存在AutoBindGlobalSetting，路径:{path}", "确认");
                return;
            }
        
            

            AutoBindGlobalSetting setting = CreateInstance<AutoBindGlobalSetting>();
            string filePath = "Assets/MotionFramework/UIKitSetting/AutoBindGlobalSetting.asset";
            string dirPath = System.IO.Path.GetDirectoryName(filePath);
			if (!System.IO.Directory.Exists(dirPath))
                System.IO.Directory.CreateDirectory(dirPath);
            AssetDatabase.CreateAsset(setting, filePath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
    }
}
